package com.group.www.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.group.www.dao.impl.CustomerfinancingDao;
import com.group.www.interfaces.CustomerFinancingServiceI;
import com.group.www.interfaces.Icustomerfinancing_q;
import com.group.www.pojo.Customerfinancing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@com.alibaba.dubbo.config.annotation.Service
@Service
public class CustomerfinancingServiceImp implements Icustomerfinancing_q,CustomerFinancingServiceI{
    @Autowired
    private CustomerfinancingDao dao;
    @Override
    public boolean add(Customerfinancing customerfinancing) {
        return dao.add(customerfinancing);
    }

    @Override
    public boolean update(Customerfinancing entity) {
        return dao.update(entity);
    }

    @Override
    public List query() {
        return dao.query();
    }

    @Override
    public boolean delete(Customerfinancing entity) {
        return dao.delete(entity);
    }

    /**GJ***/
    @Override
    public boolean addCustFin(Customerfinancing brandfinancing) {
        return dao.add(brandfinancing);
    }

    @Override
    public PageInfo<Customerfinancing> queryAll(int cfId, int pageIndex, int pageSize) {
        /**分页**/
        PageHelper.startPage(pageIndex,pageSize);
        List<Customerfinancing> list= dao.queryAll();
        PageInfo<Customerfinancing> page=new PageInfo<>(list);
        return page;
    }

    @Override
    public Customerfinancing queryById(Integer cfId) {
        return dao.queryById(cfId);
    }

    @Override
    public boolean updateCustFin(Customerfinancing customerfinancing) {
        return dao.update(customerfinancing);
    }

    @Override
    public boolean daleteCustFin(Customerfinancing customerfinancing) {
        return dao.delete(customerfinancing);
    }

    @Override
    public boolean daleteMany(String brandIs) {
        boolean flag=false;
        String idstrs []=brandIs.split(",");
        for (int i=0;i<idstrs.length;i++){
            Customerfinancing customerfinancing=new Customerfinancing();
            customerfinancing.setCfId(Integer.parseInt(idstrs[i]));
            flag=dao.delete(customerfinancing);
        }
        return flag;
    }
}
